<!-- <template>
    <div class="addEdit-block">
        <el-form
                class="detail-form-content"
                ref="ruleForm"
                :model="ruleForm"
                :rules="rules"
                label-width="auto"
                >
            <el-row>
                <input id="updateId" name="id" type="hidden">
               <el-col :span="12">
                   <el-form-item class="input" v-if="type!='info'"  label="中医药文化知识名称" prop="xiquName">
                       <el-input v-model="ruleForm.xiquName"
                                 placeholder="中医药文化知识名称" clearable  :readonly="ro.xiquName"></el-input>
                   </el-form-item>
                   <div v-else-if="type=='info'">
                       <el-form-item class="input" label="中医药文化知识名称" prop="xiquName">
                           <el-input v-model="ruleForm.xiquName"
                                     placeholder="中医药文化知识名称" readonly></el-input>
                       </el-form-item>
                   </div>
               </el-col>
               <el-col :span="12">
                   <el-form-item class="input" v-if="type!='info'"  label="中医药文化知识编号" prop="xiquUuidNumber">
                       <el-input v-model="ruleForm.xiquUuidNumber"
                                 placeholder="中医药文化知识编号" clearable  :readonly="ro.xiquUuidNumber"></el-input>
                   </el-form-item>
                   <div v-else-if="type=='info'">
                       <el-form-item class="input" label="中医药文化知识编号" prop="xiquUuidNumber">
                           <el-input v-model="ruleForm.xiquUuidNumber"
                                     placeholder="中医药文化知识编号" readonly></el-input>
                       </el-form-item>
                   </div>
               </el-col>
                <el-col :span="12">
                    <el-form-item class="upload" v-if="type!='info' && !ro.xiquPhoto" label="中医药文化知识照片" prop="xiquPhoto">
                        <file-upload
                            tip="点击上传中医药文化知识照片"
                            action="file/upload"
                            :limit="3"
                            :multiple="true"
                            :fileUrls="ruleForm.xiquPhoto?$base.url+ruleForm.xiquPhoto:''"
                            @change="xiquPhotoUploadChange"
                        ></file-upload>
                    </el-form-item>
                    <div v-else>
                        <el-form-item v-if="ruleForm.xiquPhoto" label="中医药文化知识照片" prop="xiquPhoto">
                            <img style="margin-right:20px;" v-bind:key="index" v-for="(item,index) in (ruleForm.xiquPhoto || '').split(',')" :src="$base.url+item" width="100" height="100">
                        </el-form-item>
                    </div>
                </el-col>
               <el-col :span="12">
                   <el-form-item class="input" v-if="type!='info'"  label="发源地" prop="xiquAddress">
                       <el-input v-model="ruleForm.xiquAddress"
                                 placeholder="发源地" clearable  :readonly="ro.xiquAddress"></el-input>
                   </el-form-item>
                   <div v-else-if="type=='info'">
                       <el-form-item class="input" label="发源地" prop="xiquAddress">
                           <el-input v-model="ruleForm.xiquAddress"
                                     placeholder="发源地" readonly></el-input>
                       </el-form-item>
                   </div>
               </el-col>
                <el-col :span="12">
                    <el-form-item class="upload" v-if="type!='info' && !ro.xiquFile" label="中医药文化知识文件" prop="xiquFile">
                        <file-upload
                                tip="点击上传中医药文化知识文件"
                                action="file/upload"
                                :limit="3"
                                :multiple="true"
                                :fileUrls="ruleForm.xiquFile?$base.url+ruleForm.xiquFile:''"
                                @change="xiquFileUploadChange"
                        ></file-upload>
                    </el-form-item>
                    <div v-else>
                        <el-form-item v-if="ruleForm.xiquFile" label="中医药文化知识文件" prop="xiquFile">
                            <a type="text" style="text-decoration:none" class="el-button" :href="$base.url+ruleForm.xiquFile"  >中医药文化知识文件下载</a>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="upload" v-if="type!='info' && !ro.xiquMusic" label="中医药文化知识音频" prop="xiquMusic">
                        <file-upload
                                tip="点击上传中医药文化知识音频"
                                action="file/upload"
                                :limit="3"
                                :multiple="true"
                                :fileUrls="ruleForm.xiquMusic?$base.url+ruleForm.xiquMusic:''"
                                @change="xiquMusicUploadChange"
                        ></file-upload>
                    </el-form-item>
                    <div v-else>
                        <el-form-item v-if="ruleForm.xiquMusic" label="中医药文化知识音频" prop="xiquMusic">
                            <audio :src="$base.url+ruleForm.xiquMusic" controls="controls"  width="100" height="100">
                                您的浏览器不支持音频播放
                            </audio>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="upload" v-if="type!='info' && !ro.xiquVideo" label="中医药文化知识视频" prop="xiquVideo">
                        <file-upload
                            tip="点击上传中医药文化知识视频"
                            action="file/upload"
                            :limit="3"
                            :multiple="true"
                            :fileUrls="ruleForm.xiquVideo?$base.url+ruleForm.xiquVideo:''"
                            @change="xiquVideoUploadChange"
                        ></file-upload>
                    </el-form-item>
                    <div v-else>
                        <el-form-item v-if="ruleForm.xiquVideo" label="中医药文化知识视频" prop="xiquVideo">
                            <video :src="$base.url+ruleForm.xiquVideo" width="100" height="100" controls="controls">
                            </video>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="select" v-if="type!='info'"  label="中医药文化知识类型" prop="xiquTypes">
                        <el-select v-model="ruleForm.xiquTypes" :disabled="ro.xiquTypes" placeholder="请选择中医药文化知识类型">
                            <el-option
                                v-for="(item,index) in xiquTypesOptions"
                                v-bind:key="item.codeIndex"
                                :label="item.indexName"
                                :value="item.codeIndex">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <div v-else-if="type=='info'">
                        <el-form-item class="input" label="中医药文化知识类型" prop="xiquValue">
                        <el-input v-model="ruleForm.xiquValue"
                            placeholder="中医药文化知识类型" readonly></el-input>
                        </el-form-item>
                    </div>
                </el-col>
               <el-col :span="12">
                   <el-form-item class="input" v-if="type!='info'"  label="赞" prop="zanNumber">
                       <el-input v-model="ruleForm.zanNumber"
                                 placeholder="赞" clearable  :readonly="ro.zanNumber"></el-input>
                   </el-form-item>
                   <div v-else-if="type=='info'">
                       <el-form-item class="input" label="赞" prop="zanNumber">
                           <el-input v-model="ruleForm.zanNumber"
                                     placeholder="赞" readonly></el-input>
                       </el-form-item>
                   </div>
               </el-col>
               <el-col :span="12">
                   <el-form-item class="input" v-if="type!='info'"  label="踩" prop="caiNumber">
                       <el-input v-model="ruleForm.caiNumber"
                                 placeholder="踩" clearable  :readonly="ro.caiNumber"></el-input>
                   </el-form-item>
                   <div v-else-if="type=='info'">
                       <el-form-item class="input" label="踩" prop="caiNumber">
                           <el-input v-model="ruleForm.caiNumber"
                                     placeholder="踩" readonly></el-input>
                       </el-form-item>
                   </div>
               </el-col>
                <el-col :span="24">
                    <el-form-item v-if="type!='info'"  label="中医药文化知识介绍" prop="xiquContent">
                        <editor style="min-width: 200px; max-width: 600px;"
                                v-model="ruleForm.xiquContent"
                                class="editor"
                                action="file/upload">
                        </editor>
                    </el-form-item>
                    <div v-else-if="type=='info'">
                        <el-form-item v-if="ruleForm.xiquContent" label="中医药文化知识介绍" prop="xiquContent">
                            <span v-html="ruleForm.xiquContent"></span>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-form-item class="btn">
                <el-button v-if="type!='info'" type="primary" class="btn-success" @click="onSubmit">提交</el-button>
                <el-button v-if="type!='info'" class="btn-close" @click="back()">取消</el-button>
                <el-button v-if="type=='info'" class="btn-close" @click="back()">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
</template> -->

<template>
  <div class="addEdit-block">
    <div class="form-container">
      <el-form
        class="detail-form-content"
        ref="ruleForm"
        :model="ruleForm"
        :rules="rules"
        label-width="140px"
      >
        <div class="form-title">
          <h2>{{ type === "info" ? "知识详情" : "知识编辑" }}</h2>
        </div>

        <el-row :gutter="20">
          <input id="updateId" name="id" type="hidden" />

          <!-- 知识名称 -->
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="知识名称：" prop="xiquName">
              <el-input
                v-model="ruleForm.xiquName"
                :placeholder="type != 'info' ? '请输入知识名称' : ''"
                :readonly="ro.xiquName"
                class="custom-input"
              ></el-input>
            </el-form-item>
          </el-col>

          <!-- 知识编号 -->
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="知识编号：" prop="xiquUuidNumber">
              <el-input
                v-model="ruleForm.xiquUuidNumber"
                :placeholder="type != 'info' ? '请输入知识编号' : ''"
                :readonly="ro.xiquUuidNumber"
                class="custom-input"
              ></el-input>
            </el-form-item>
          </el-col>

          <!-- 知识照片 -->
          <el-col :span="24">
            <el-form-item label="知识照片：" prop="xiquPhoto">
              <file-upload
                v-if="type != 'info' && !ro.xiquPhoto"
                tip="点击上传照片"
                action="file/upload"
                :limit="3"
                :multiple="true"
                :fileUrls="
                  ruleForm.xiquPhoto ? $base.url + ruleForm.xiquPhoto : ''
                "
                @change="xiquPhotoUploadChange"
                class="custom-upload"
              ></file-upload>
              <div v-else class="upload-preview">
                <img
                  v-for="(item, index) in (ruleForm.xiquPhoto || '').split(',')"
                  :key="index"
                  :src="$base.url + item"
                  class="preview-image"
                />
              </div>
            </el-form-item>
          </el-col>

          <!-- 发源地 -->
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="发源地：" prop="xiquAddress">
              <el-input
                v-model="ruleForm.xiquAddress"
                :placeholder="type != 'info' ? '请输入发源地' : ''"
                :readonly="ro.xiquAddress"
                class="custom-input"
              ></el-input>
            </el-form-item>
          </el-col>

          <!-- 文件上传 -->
          <el-col :span="24">
            <el-form-item label="知识文件：" prop="xiquFile">
              <file-upload
                v-if="type != 'info' && !ro.xiquFile"
                tip="点击上传文件"
                action="file/upload"
                :limit="3"
                :fileUrls="
                  ruleForm.xiquFile ? $base.url + ruleForm.xiquFile : ''
                "
                @change="xiquFileUploadChange"
                class="custom-upload"
              ></file-upload>
              <div v-else class="file-preview">
                <a
                  v-if="ruleForm.xiquFile"
                  :href="$base.url + ruleForm.xiquFile"
                  class="file-link"
                >
                  <i class="el-icon-document"></i>
                  下载文件
                </a>
              </div>
            </el-form-item>
          </el-col>

          <!-- 富文本编辑器 -->
          <el-col :span="24">
            <el-form-item label="知识介绍：" prop="xiquContent">
              <editor
                v-if="type != 'info'"
                v-model="ruleForm.xiquContent"
                class="custom-editor"
                action="file/upload"
                style="min-width: 200px; max-width: 100%"
              ></editor>
              <div
                v-else
                class="content-view"
                v-html="ruleForm.xiquContent"
              ></div>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item class="form-action">
          <el-button
            v-if="type != 'info'"
            type="primary"
            icon="el-icon-check"
            class="btn-submit"
            @click="onSubmit"
          >
            提交
          </el-button>
          <el-button class="btn-cancel" icon="el-icon-close" @click="back">
            {{ type == "info" ? "返回" : "取消" }}
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import styleJs from "../../../utils/style.js";
// 数字，邮件，手机，url，身份证校验
import {
  isNumber,
  isIntNumer,
  isEmail,
  isPhone,
  isMobile,
  isURL,
  checkIdCard,
} from "@/utils/validate";
import utilsJs, {
  getYearFormat,
  getMonthFormat,
  getDateFormat,
  getDatetimeFormat,
} from "../../../utils/utils.js";
export default {
  data() {
    return {
      addEditForm: null,
      id: "",
      type: "",
      sessionTable: "", //登录账户所在表名
      role: "", //权限
      userId: "", //当前登录人的id
      ro: {
        xiquName: false,
        xiquUuidNumber: false,
        xiquPhoto: false,
        xiquAddress: false,
        xiquFile: false,
        xiquMusic: false,
        xiquVideo: false,
        xiquTypes: false,
        zanNumber: false,
        caiNumber: false,
        xiquClicknum: false,
        xiquContent: false,
        shangxiaTypes: false,
        xiquDelete: false,
        insertTime: false,
      },
      ruleForm: {
        xiquName: "",
        xiquUuidNumber: new Date().getTime(),
        xiquPhoto: "",
        xiquAddress: "",
        xiquFile: "",
        xiquMusic: "",
        xiquVideo: "",
        xiquTypes: "",
        zanNumber: "",
        caiNumber: "",
        xiquClicknum: "",
        xiquContent: "",
        shangxiaTypes: "",
        xiquDelete: "",
        insertTime: "",
      },
      xiquTypesOptions: [],
      shangxiaTypesOptions: [],
      rules: {
        xiquName: [
          {
            required: true,
            message: "中医药文化知识名称不能为空",
            trigger: "blur",
          },
        ],
        xiquUuidNumber: [
          {
            required: true,
            message: "中医药文化知识编号不能为空",
            trigger: "blur",
          },
        ],
        xiquPhoto: [
          {
            required: true,
            message: "中医药文化知识照片不能为空",
            trigger: "blur",
          },
        ],
        xiquAddress: [
          { required: true, message: "发源地不能为空", trigger: "blur" },
        ],
        xiquFile: [
          {
            required: true,
            message: "中医药文化知识文件不能为空",
            trigger: "blur",
          },
        ],
        xiquMusic: [
          {
            required: true,
            message: "中医药文化知识音频不能为空",
            trigger: "blur",
          },
        ],
        xiquVideo: [
          {
            required: true,
            message: "中医药文化知识视频不能为空",
            trigger: "blur",
          },
        ],
        xiquTypes: [
          {
            required: true,
            message: "中医药文化知识类型不能为空",
            trigger: "blur",
          },
          { pattern: /^[0-9]*$/, message: "只允许输入整数", trigger: "blur" },
        ],
        zanNumber: [
          { required: true, message: "赞不能为空", trigger: "blur" },
          { pattern: /^[0-9]*$/, message: "只允许输入整数", trigger: "blur" },
        ],
        caiNumber: [
          { required: true, message: "踩不能为空", trigger: "blur" },
          { pattern: /^[0-9]*$/, message: "只允许输入整数", trigger: "blur" },
        ],
        xiquClicknum: [
          {
            required: true,
            message: "中医药文化知识热度不能为空",
            trigger: "blur",
          },
          { pattern: /^[0-9]*$/, message: "只允许输入整数", trigger: "blur" },
        ],
        xiquContent: [
          {
            required: true,
            message: "中医药文化知识介绍不能为空",
            trigger: "blur",
          },
        ],
        shangxiaTypes: [
          { required: true, message: "是否上架不能为空", trigger: "blur" },
          { pattern: /^[0-9]*$/, message: "只允许输入整数", trigger: "blur" },
        ],
        xiquDelete: [
          { required: true, message: "逻辑删除不能为空", trigger: "blur" },
          { pattern: /^[0-9]*$/, message: "只允许输入整数", trigger: "blur" },
        ],
        insertTime: [
          { required: true, message: "录入时间不能为空", trigger: "blur" },
        ],
      },
    };
  },
  props: ["parent"],
  computed: {},
  created() {
    //获取当前登录用户的信息
    this.sessionTable = this.$storage.get("sessionTable");
    this.role = this.$storage.get("role");
    this.userId = this.$storage.get("userId");

    if (this.role != "管理员") {
    }
    this.addEditForm = styleJs.addStyle();
    this.addEditStyleChange();
    this.addEditUploadStyleChange();
    //获取下拉框信息
    this.$http({
      url: `dictionary/page?page=1&limit=100&sort=&order=&dicCode=xiqu_types`,
      method: "get",
    }).then(({ data }) => {
      if (data && data.code === 0) {
        this.xiquTypesOptions = data.data.list;
      }
    });
    this.$http({
      url: `dictionary/page?page=1&limit=100&sort=&order=&dicCode=shangxia_types`,
      method: "get",
    }).then(({ data }) => {
      if (data && data.code === 0) {
        this.shangxiaTypesOptions = data.data.list;
      }
    });
  },
  mounted() {},
  methods: {
    // 下载
    download(file) {
      window.open(`${file}`);
    },
    // 初始化
    init(id, type) {
      if (id) {
        this.id = id;
        this.type = type;
      }
      if (this.type == "info" || this.type == "else") {
        this.info(id);
      }
      // 获取用户信息
      this.$http({
        url: `${this.$storage.get("sessionTable")}/session`,
        method: "get",
      }).then(({ data }) => {
        if (data && data.code === 0) {
          var json = data.data;
        } else {
          this.$message.error(data.msg);
        }
      });
    },
    // 多级联动参数
    info(id) {
      let _this = this;
      _this
        .$http({
          url: `xiqu/info/${id}`,
          method: "get",
        })
        .then(({ data }) => {
          if (data && data.code === 0) {
            _this.ruleForm = data.data;
            _this.ruleForm.xiquContent = _this.ruleForm.xiquContent.replaceAll(
              'src="upload/',
              'src="' + this.$base.url + "upload/"
            );
          } else {
            _this.$message.error(data.msg);
          }
        });
    },
    // 提交
    onSubmit() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          this.ruleForm.xiquContent = this.ruleForm.xiquContent.replaceAll(
            this.$base.url,
            ""
          );
          this.$http({
            url: `xiqu/${!this.ruleForm.id ? "save" : "update"}`,
            method: "post",
            data: this.ruleForm,
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.$message({
                message: "操作成功",
                type: "success",
                duration: 1500,
                onClose: () => {
                  this.parent.showFlag = true;
                  this.parent.addOrUpdateFlag = false;
                  this.parent.xiquCrossAddOrUpdateFlag = false;
                  this.parent.search();
                  this.parent.contentStyleChange();
                },
              });
            } else {
              this.$message.error(data.msg);
            }
          });
        }
      });
    },
    // 获取uuid
    getUUID() {
      return new Date().getTime();
    },
    // 返回
    back() {
      this.parent.showFlag = true;
      this.parent.addOrUpdateFlag = false;
      this.parent.xiquCrossAddOrUpdateFlag = false;
      this.parent.contentStyleChange();
    },
    //图片
    xiquPhotoUploadChange(fileUrls) {
      this.ruleForm.xiquPhoto = fileUrls;
      this.addEditUploadStyleChange();
    },
    xiquFileUploadChange(fileUrls) {
      this.ruleForm.xiquFile = fileUrls;
      this.addEditUploadStyleChange();
    },
    xiquMusicUploadChange(fileUrls) {
      this.ruleForm.xiquMusic = fileUrls;
      this.addEditUploadStyleChange();
    },
    xiquVideoUploadChange(fileUrls) {
      this.ruleForm.xiquVideo = fileUrls;
      this.addEditUploadStyleChange();
    },

    addEditStyleChange() {
      this.$nextTick(() => {
        // input
        document
          .querySelectorAll(".addEdit-block .input .el-input__inner")
          .forEach((el) => {
            el.style.height = this.addEditForm.inputHeight;
            el.style.color = this.addEditForm.inputFontColor;
            el.style.fontSize = this.addEditForm.inputFontSize;
            el.style.borderWidth = this.addEditForm.inputBorderWidth;
            el.style.borderStyle = this.addEditForm.inputBorderStyle;
            el.style.borderColor = this.addEditForm.inputBorderColor;
            el.style.borderRadius = this.addEditForm.inputBorderRadius;
            el.style.backgroundColor = this.addEditForm.inputBgColor;
          });
        document
          .querySelectorAll(".addEdit-block .input .el-form-item__label")
          .forEach((el) => {
            el.style.lineHeight = this.addEditForm.inputHeight;
            el.style.color = this.addEditForm.inputLableColor;
            el.style.fontSize = this.addEditForm.inputLableFontSize;
          });
        // select
        document
          .querySelectorAll(".addEdit-block .select .el-input__inner")
          .forEach((el) => {
            el.style.height = this.addEditForm.selectHeight;
            el.style.color = this.addEditForm.selectFontColor;
            el.style.fontSize = this.addEditForm.selectFontSize;
            el.style.borderWidth = this.addEditForm.selectBorderWidth;
            el.style.borderStyle = this.addEditForm.selectBorderStyle;
            el.style.borderColor = this.addEditForm.selectBorderColor;
            el.style.borderRadius = this.addEditForm.selectBorderRadius;
            el.style.backgroundColor = this.addEditForm.selectBgColor;
          });
        document
          .querySelectorAll(".addEdit-block .select .el-form-item__label")
          .forEach((el) => {
            el.style.lineHeight = this.addEditForm.selectHeight;
            el.style.color = this.addEditForm.selectLableColor;
            el.style.fontSize = this.addEditForm.selectLableFontSize;
          });
        document
          .querySelectorAll(".addEdit-block .select .el-select__caret")
          .forEach((el) => {
            el.style.color = this.addEditForm.selectIconFontColor;
            el.style.fontSize = this.addEditForm.selectIconFontSize;
          });
        // date
        document
          .querySelectorAll(".addEdit-block .date .el-input__inner")
          .forEach((el) => {
            el.style.height = this.addEditForm.dateHeight;
            el.style.color = this.addEditForm.dateFontColor;
            el.style.fontSize = this.addEditForm.dateFontSize;
            el.style.borderWidth = this.addEditForm.dateBorderWidth;
            el.style.borderStyle = this.addEditForm.dateBorderStyle;
            el.style.borderColor = this.addEditForm.dateBorderColor;
            el.style.borderRadius = this.addEditForm.dateBorderRadius;
            el.style.backgroundColor = this.addEditForm.dateBgColor;
          });
        document
          .querySelectorAll(".addEdit-block .date .el-form-item__label")
          .forEach((el) => {
            el.style.lineHeight = this.addEditForm.dateHeight;
            el.style.color = this.addEditForm.dateLableColor;
            el.style.fontSize = this.addEditForm.dateLableFontSize;
          });
        document
          .querySelectorAll(".addEdit-block .date .el-input__icon")
          .forEach((el) => {
            el.style.color = this.addEditForm.dateIconFontColor;
            el.style.fontSize = this.addEditForm.dateIconFontSize;
            el.style.lineHeight = this.addEditForm.dateHeight;
          });
        // upload
        let iconLineHeight =
          parseInt(this.addEditForm.uploadHeight) -
          parseInt(this.addEditForm.uploadBorderWidth) * 2 +
          "px";
        document
          .querySelectorAll(".addEdit-block .upload .el-upload--picture-card")
          .forEach((el) => {
            el.style.width = this.addEditForm.uploadHeight;
            el.style.height = this.addEditForm.uploadHeight;
            el.style.borderWidth = this.addEditForm.uploadBorderWidth;
            el.style.borderStyle = this.addEditForm.uploadBorderStyle;
            el.style.borderColor = this.addEditForm.uploadBorderColor;
            el.style.borderRadius = this.addEditForm.uploadBorderRadius;
            el.style.backgroundColor = this.addEditForm.uploadBgColor;
          });
        document
          .querySelectorAll(".addEdit-block .upload .el-form-item__label")
          .forEach((el) => {
            el.style.lineHeight = this.addEditForm.uploadHeight;
            el.style.color = this.addEditForm.uploadLableColor;
            el.style.fontSize = this.addEditForm.uploadLableFontSize;
          });
        document
          .querySelectorAll(".addEdit-block .upload .el-icon-plus")
          .forEach((el) => {
            el.style.color = this.addEditForm.uploadIconFontColor;
            el.style.fontSize = this.addEditForm.uploadIconFontSize;
            el.style.lineHeight = iconLineHeight;
            el.style.display = "block";
          });
        // 多文本输入框
        document
          .querySelectorAll(".addEdit-block .textarea .el-textarea__inner")
          .forEach((el) => {
            el.style.height = this.addEditForm.textareaHeight;
            el.style.color = this.addEditForm.textareaFontColor;
            el.style.fontSize = this.addEditForm.textareaFontSize;
            el.style.borderWidth = this.addEditForm.textareaBorderWidth;
            el.style.borderStyle = this.addEditForm.textareaBorderStyle;
            el.style.borderColor = this.addEditForm.textareaBorderColor;
            el.style.borderRadius = this.addEditForm.textareaBorderRadius;
            el.style.backgroundColor = this.addEditForm.textareaBgColor;
          });
        document
          .querySelectorAll(".addEdit-block .textarea .el-form-item__label")
          .forEach((el) => {
            // el.style.lineHeight = this.addEditForm.textareaHeight
            el.style.color = this.addEditForm.textareaLableColor;
            el.style.fontSize = this.addEditForm.textareaLableFontSize;
          });
        // 保存
        document
          .querySelectorAll(".addEdit-block .btn .btn-success")
          .forEach((el) => {
            el.style.width = this.addEditForm.btnSaveWidth;
            el.style.height = this.addEditForm.btnSaveHeight;
            el.style.color = this.addEditForm.btnSaveFontColor;
            el.style.fontSize = this.addEditForm.btnSaveFontSize;
            el.style.borderWidth = this.addEditForm.btnSaveBorderWidth;
            el.style.borderStyle = this.addEditForm.btnSaveBorderStyle;
            el.style.borderColor = this.addEditForm.btnSaveBorderColor;
            el.style.borderRadius = this.addEditForm.btnSaveBorderRadius;
            el.style.backgroundColor = this.addEditForm.btnSaveBgColor;
          });
        // 返回
        document
          .querySelectorAll(".addEdit-block .btn .btn-close")
          .forEach((el) => {
            el.style.width = this.addEditForm.btnCancelWidth;
            el.style.height = this.addEditForm.btnCancelHeight;
            el.style.color = this.addEditForm.btnCancelFontColor;
            el.style.fontSize = this.addEditForm.btnCancelFontSize;
            el.style.borderWidth = this.addEditForm.btnCancelBorderWidth;
            el.style.borderStyle = this.addEditForm.btnCancelBorderStyle;
            el.style.borderColor = this.addEditForm.btnCancelBorderColor;
            el.style.borderRadius = this.addEditForm.btnCancelBorderRadius;
            el.style.backgroundColor = this.addEditForm.btnCancelBgColor;
          });
      });
    },
    addEditUploadStyleChange() {
      this.$nextTick(() => {
        document
          .querySelectorAll(
            ".addEdit-block .upload .el-upload-list--picture-card .el-upload-list__item"
          )
          .forEach((el) => {
            el.style.width = this.addEditForm.uploadHeight;
            el.style.height = this.addEditForm.uploadHeight;
            el.style.borderWidth = this.addEditForm.uploadBorderWidth;
            el.style.borderStyle = this.addEditForm.uploadBorderStyle;
            el.style.borderColor = this.addEditForm.uploadBorderColor;
            el.style.borderRadius = this.addEditForm.uploadBorderRadius;
            el.style.backgroundColor = this.addEditForm.uploadBgColor;
          });
      });
    },
  },
};
</script>
<style scoped>
.addEdit-block {
  /* height: 100vh; */
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.form-container {
  width: 90%;
  /* max-width: 1000px; */
  padding: 30px 40px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.form-title {
  text-align: center;
  margin-bottom: 30px;
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
}

.form-title h2 {
  font-size: 24px;
  color: #303133;
  margin: 0;
  font-weight: 600;
  letter-spacing: 1px;
}

.custom-input ::v-deep .el-input__inner {
  height: 48px;
  border-radius: 8px;
  font-size: 16px;
}

.custom-upload {
  margin-top: 10px;
}

.upload-preview {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.preview-image {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #ebeef5;
}

.file-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 15px;
  background: #f5f7fa;
  border-radius: 6px;
  color: #409eff;
}

.custom-editor ::v-deep .w-e-text-container {
  border-radius: 8px !important;
  min-height: 200px;
}

.content-view {
  padding: 15px;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  background: #f8f9fa;
}

.form-action {
  margin-top: 40px;
  text-align: center;
}

.btn-submit {
  padding: 12px 35px;
  font-size: 16px;
  border-radius: 8px;
}

.btn-cancel {
  padding: 12px 35px;
  font-size: 16px;
  border-radius: 8px;
  margin-left: 20px;
}

@media (max-width: 768px) {
  .form-container {
    padding: 20px;
  }

  .el-col {
    margin-bottom: 20px;
  }

  .form-action {
    margin-top: 20px;
  }

  .btn-submit,
  .btn-cancel {
    width: 100%;
    margin-left: 0;
    margin-top: 10px;
  }

  .preview-image {
    width: 100%;
    height: auto;
  }
}
</style>
